package com.iamteer.day24;

import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.net.InetAddress;
import java.net.Socket;

public class ImageClient {

	public static void main(String[] args) throws IOException {
		String fileName = Long.toString(System.currentTimeMillis()) + ".jpg";
		Socket socket = new Socket(InetAddress.getLocalHost(), 9090);
		InputStream in = socket.getInputStream();
		FileOutputStream out = new FileOutputStream(fileName);
		byte[] b = new byte[1024];
		int len = -1;
		while ((len = in.read(b)) != -1) {
			out.write(b, 0, len);
		}
		out.close();
		socket.close();
	}

}
